﻿<?php
    include_once("../action/checkAuthenticationAction.php");
    include_once("../service/branchService.php");
    include_once("../util/constant.php");
    
    include_once("../util/authUtil.php");
    $perm_array = $_SESSION["permissions"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Dashboard</title>
	<?php include("import-css.php");?>	
</head>
<body>
	<?php include("header.php");?>
    
    <div class="container-fluid">
		<div class="row-fluid">
            <!--Menu-->
            <?php include("menu.php");?>
            <!--Content-->
            <div class="box span10 offset2">
    					<div class="box-header well" data-original-title>
                            <?php
                                $require_perm = array("create branch");
                                if(authUtil($require_perm,$perm_array,true)){
                            ?>
            						<a class="btn btn-primary" href="./branch-detail.php?action=<?php echo NEW_ACTION; ?>">
                                        <i class="icon-edit icon-white"></i>Thêm mới
                                    </a>
                            <?php
                                }
                            ?>
    						<div class="box-icon">
    							<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
    						</div>
    					</div>
    					<div class="box-content">
    						<table class="table table-striped table-bordered bootstrap-datatable datatable">
    						  <thead>
    							  <tr>
    								  <th>Tên chi nhánh</th>
    								  <th>Thứ tự</th>
    								  <th>Chức năng</th>
    							  </tr>
    						  </thead>   
    						  <tbody>
									<?php
									$branches = getAllBranch();
									while($branch = mysql_fetch_array($branches)){
										?>
											<tr>
												<td><?php echo $branch["BRA_NAME"]; ?></td>
												<td><?php echo $branch["BRA_ORDER"]; ?></td>
												<td class="center">
													<a href="#branchModal<?php echo $branch['BRA_ID']; ?>" role="button" class="btn btn-success" data-toggle="modal">
														<i class="icon-zoom-in icon-white"></i>  
														Xem thông tin
													</a>
													<!--Preview Category Information Modal-->
													<div class="modal hide fade" id="branchModal<?php echo $branch['BRA_ID']; ?>">
														<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
															<?php echo $branch["BRA_NAME"]; ?>
														</div>
														<div class="modal-body">
															<?php echo $branch['BRA_ADDRESS']; ?>
														</div>
														<div class="modal-footer">
														</div>
													</div>
                                                    <?php
                                                        $require_perm = array("edit branch","create branch");
                                                        if(authUtil($require_perm,$perm_array,false)){
                                                    ?>
        													<a class="btn btn-info" href="./branch-detail.php?action=<?php echo EDIT_ACTION; ?>&id=<?php echo $branch['BRA_ID']; ?>">
        														<i class="icon-edit icon-white"></i>  
        														Cập nhật
        													</a>
                                                    <?php
                                                        }
    												?>
                                                    <?php
                                                        $require_perm = array("delete branch");
                                                        if(authUtil($require_perm,$perm_array,true)){
                                                    ?>
        													<a class="btn btn-danger" href="../action/deleteBranchAction.php?id=<?php echo $branch['BRA_ID']; ?>">
        														<i class="icon-trash icon-white"></i>
        														Xóa
        													</a>
                                                    <?php
                                                        }
    												?>
                                            </td>
											</tr>
										<?php									
									}
									?>
    						  </tbody>
    					  </table>            
                        </div>
            </div><!--/span-->
        </div>
    </div>

    <?php include("footer.php");?>
		
	</div><!--/.fluid-container-->

	<?php include("import-js.php");?>	
    
</body>
</html>
